package com.jinzhi.jzweb.utils;

import com.jinzhi.jzweb.pojo.StuSignUpTeamVo;
import org.apache.poi.ss.formula.functions.T;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class FractionUtil {


    public static List<StuSignUpTeamVo> teamList(  List<StuSignUpTeamVo> mapList){
        List<StuSignUpTeamVo> mapLists=new ArrayList<>();
        for(StuSignUpTeamVo obj:mapList){
            Double sour=obj.getTotalScore();
            Double f=(sour*0.15)+(((obj.getScore1()+obj.getScore2()+obj.getScore3())/3)*0.15);
            BigDecimal bg = new BigDecimal(f);
            double f1 = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
            //A赛场个人统计
            obj.setTeamSumA(f1);
            Double b=((obj.getScoingb1()+obj.getScoingb2()+obj.getScoingb3()+obj.getScoingb4()+obj.getScoingb5())/5)*0.2;
            Double b1=((obj.getScoingb3s()+obj.getScoingb2s()+obj.getScoingb1s()+obj.getScoingb4s()+obj.getScoingb5s())/5)*0.2;
            BigDecimal bp = new BigDecimal(b+b1);
            double bs = bp.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
            //B赛场
            obj.setTeamSumB(bs);
            Double c=((obj.getScoingc1()+obj.getScoingc2()+obj.getScoingc3()+obj.getScoingc4()+obj.getScoingc5())/5)*0.15;
            Double c1=((obj.getScoingc3s()+obj.getScoingc2s()+obj.getScoingc1s()+obj.getScoingc4s()+obj.getScoingc5s())/5)*0.15;
            BigDecimal cp = new BigDecimal(c+c1);
            double cs = cp.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
            //c赛场
            obj.setTeamSumC(cs);
            Double tatlo=(f1+bs+cs);
            BigDecimal bgs = new BigDecimal(tatlo);
            double tatlos = bgs.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
            // obj.setTeamSumC(tatlos);
            //计算俩个选手的总分
            obj.setTeamTotal(tatlos);
            mapLists.add(obj);
        }
        mapLists.sort((a,b) -> b.getTeamTotal().compareTo(a.getTeamTotal()));
        return mapLists;

    }
}
